<template>
  <div class="index">
    <div class="sidebar">
      <MyCard></MyCard>
    </div>
    <div class="main">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import MyCard from "./child/myCard";
import { mapActions } from "vuex";

export default {
  components: {
    MyCard
  },
  created() {
    this.loadData();
    // 检查是否有获取通知的权限
    this.checkPermission();
  },
  methods: {
    ...mapActions(["loadData"]),
    checkPermission() {
      // 首先，让我们检查我们是否有权限发出通知
      // 如果没有，我们就请求获得权限
      if (window.Notification && Notification.permission !== "granted") {
        Notification.requestPermission(function(status) {
          if (Notification.permission !== status) {
            Notification.permission = status;
          }
        });
      }
    }
  }
};
</script>

<style scoped>
.index {
  display: flex;
  border-radius: 50px;
  margin: 20px auto;
  width: 860px;
  height: 600px;
  background-color: #fff;
}

.sidebar {
  width: 60px;
  height: 600px;
  background-color: #2b2c2f;
}

.main {
  flex: 1;
  height: 600px;
  background-color: #f2f2f2;
}
</style>